package com.surfing.util;

import com.surfing.R;
import com.surfing.disscusgroup.DisscusActivity;
import com.surfing.httpconnection.ImageDownloader;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

public class TitleBarDisplay
{
    public static void TitleBarInit(TextView mTitleText,ImageView mTitleIcon,Activity activity,Context context){ 
        int mTheme = ReadConfigFile.getTheme(context);
        Context mCurrentContext = ReadConfigFile.getCurrentThemeContext(mTheme,context); 
        
        String enterprise_name = null;
        String enterprise_iconAddress = null;
        SharedPreferences pref = context.getSharedPreferences("enterprise",Context.MODE_PRIVATE);
        enterprise_name = pref.getString("enterprise_name","");
        enterprise_iconAddress = pref.getString("enterprise_icon_url",null);
        Log.i("TitleBarDisplay","enterprise_name == "+enterprise_name);
        mTitleText.setText(enterprise_name);
        ImageDownloader imageDownloader = new ImageDownloader();
        imageDownloader.download(enterprise_iconAddress,mTitleIcon,R.drawable.icon,context);
        DisplayWeather.updateWeatherDisplay(context,activity);
        View view = activity.findViewById(R.id.title_layout_id);
        ThemeUpdateUitl.updateTitlebarBg(view, mCurrentContext,R.drawable.title_bg);
    }
    public static String getEnterpriseName(Context context){
        String enterprise_name = null;
        SharedPreferences pref = context.getSharedPreferences("enterprise",Context.MODE_PRIVATE);
        enterprise_name = pref.getString("enterprise_name","enterprise");
        return enterprise_name;
    }
    public static String getUserName(Context context){
        SharedPreferences userpref = context.getSharedPreferences("user",Context.MODE_PRIVATE);
        String user_name = userpref.getString("user_name", "");
        return user_name;
    }
}
